<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage" :autoLoad="false">
    </ex_super_table_page>
  </div>
</template>

<script>
import business_function from "@/common/business_function"
import SuperTablePageFunction from '@/mixin/super-table-page-function';

export default {
  name: "title_stock_snapshot_query",
  title: 'title_stock_snapshot_query',
  mixins: [SuperTablePageFunction],
  components: {},
  data() {
    return {
      option: {
        //搜索框内容
        search: {
          //搜索框内容，key为搜索字段，label为标签提示
          model: [
            {
              label: "label_snapshot_time",
              key: "backupName",
              type: 'select',
              url: '/wms-api/stock/WmsStockHistoryRpc/showTableNames.json',
              option: { label: 'label', value: 'value' },
              on: {
                'initList': (result) => {
                  if (!_.isEmpty(result)) {
                    this.$refs['SuperTablePage'].$refs['search'].set("backupName", result[0].value)
                    this.$refs['SuperTablePage'].loadDataForSearch()
                  }
                }
              }

            },

            { label: "label_customer", key: "customerId", type: 'common_customer_choose', },
            { label: "label_sku", key: "skuId", type: 'sku_selec_input', },
            {
              label: "label_putaway_time",
              key: "putawayTimeStart",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "-",
              key: "putawayTimeEnd",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', click: this.exportExcel
          },
        ],
        table: {
          url: "/wms-api/stock/WmsStockHistoryRpc/stockContainerQuery.json",
          attrs: {

          },
          model: [
            {
              key: 'skuOnlyCode', label: 'label_sku_only_code',
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'skuName', label: 'label_sku_name_cn',
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'customerCode', label: 'label_srm_api_request_customer_code',
            },
            {
              key: 'customerName', label: 'label_customer_name',
            },
            {
              key: 'putawayTime', label: 'label_putaway_time', formatter: (r, c, v, i) => this.$dateFormat(v)
            },
            {
              key: 'areaCode', label: 'label_warehouse_area_code',
            },
            {
              key: 'locationCode', label: 'label_warehouse_location',
            },
            {
              key: 'containerCode', label: 'label_container_code',
            },
            {
              key: 'subContainerCode', label: 'label_sub_container_code',
            },
            {
              key: 'freezeQty', label: 'label_frozen_count',
            },
            {
              key: 'lockQty', label: 'label_lock_count',
            },
            {
              key: 'usableQty', label: 'label_usable_count',
            },
            {
              key: 'totalQty', label: 'label_sum',
            },
            {
              key: 'skuVolume', label: 'label_volume',
            },
            {
              key: 'stockAge', label: 'label_snapshot_stock'
            }
          ],

        },

      },
    }
  },
  methods: {
    exportExcel() {
      const searchParams = this.$refs.SuperTablePage.getSearchData()
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: searchParams,
        model: this.option.search.model,
        callback: (selection, data) => {
          let params = data
          this.$functionCommon({
            url: "/wms-api/stock/WmsStockHistoryRpc/stockContainerHistoryExportExcel.json",
            data: params, type: 'form',
          })
        }
      })


    },
  }

}
</script>

<style scoped></style>
